package web.api.global.convertor;

import web.api.global.message.LoginApiRequest;
import web.api.global.message.RegisterApiRequest;
import web.base.user.message.UserRequest;

/**
 * @author Jin Zheng
 * @since 1.0 2022-01-25
 */
public class UserConvertor {
	private UserConvertor() {
	}

	public static UserRequest toRequest(RegisterApiRequest request) {
		if (request == null) {
			return null;
		}
		UserRequest req = new UserRequest();
		req.setMobile(request.getMobile());
		req.setName(request.getName());
		req.setPassword(request.getPassword());
		req.setPassword2(request.getPassword2());
		return req;
	}

	public static UserRequest toRequest(LoginApiRequest request) {
		if (request == null) {
			return null;
		}
		UserRequest req = new UserRequest();
		req.setMobile(request.getMobile());
		req.setPassword(request.getPassword());
		return req;
	}

}
